﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model
{
    public class ClsPumpeCol
    {
        public List<ClsPumpe> Pumper { get; private set; }

        public ClsPumpeCol()
        {
            this.Pumper = new List<ClsPumpe>();
        }

        public void TilføjPumpe(ClsPumpe Pumpe)
        {
            lock (this.Pumper)
            {
                this.Pumper.Add(Pumpe);
            }
        }

        public bool startPumpe(int PumpeId)
        {
            ClsPumpe P = this.Pumper.SingleOrDefault(val => val.Id == PumpeId);

            if (P != null)
            {
                P.Start();
                return true;
            }
            return false;
        }

        public bool SlukPumpe(int PumpeId)
        {
            ClsPumpe P = this.Pumper.SingleOrDefault(val => val.Id == PumpeId);

            if (P != null)
            {
                P.Sluk();
                return true;
            }
            return false;
        }

        public void DefektPumpe(int PumpeId, bool Defekt)
        {
            ClsPumpe P = this.Pumper.SingleOrDefault(val => val.Id == PumpeId);
            if (P != null)
            {
                P.DefektPumpe(Defekt);
            }
        }
    }
}
